import request from '@/utils/request'
const apiUrl = '/api/machine-equipment'
// 机器设备API
export function getMachineList(params) {
    return request({
        url: `${apiUrl}/page`,
        method: 'get',
        params
    })
}

export function getMachineDetail(id) {
    return request({
        url: `${apiUrl}/${id}`,
        method: 'get'
    })
}

export function saveMachine(data) {
    return request({
        url: `${apiUrl}/save`,
        method: 'post',
        data
    })
}

export function deleteMachine(id) {
    return request({
        url: `${apiUrl}/${id}`,
        method: 'delete'
    })
}

export function deleteMachineBatch(ids) {
    return request({
        url: `${apiUrl}/batch`,
        method: 'delete',
        data: ids
    })
}

// 维护记录API
export function getMaintenanceList(machineId) {
    return request({
        url: `${apiUrl}/list/${machineId}`,
        method: 'get'
    })
}

export function saveMaintenance(data) {
    return request({
        url: `${apiUrl}/save`,
        method: 'post',
        data
    })
}

export function saveMaintenanceBatch(data) {
    return request({
        url: `${apiUrl}/batch-save`,
        method: 'post',
        data
    })
}

export function deleteMaintenance(id) {
    return request({
        url: `${apiUrl}/${id}`,
        method: 'delete'
    })
}

export function deleteMaintenanceBatch(ids) {
    return request({
        url: `${apiUrl}/batch`,
        method: 'delete',
        data: ids
    })
}

// 保存机器设备和维护记录
export function saveWithMaintenance(data) {
    return request({
        url: `${apiUrl}/save-with-maintenance`,
        method: 'post',
        data
    })
} 